home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ObjModelTokens.h
-
- Contains: Token classes interface
-
- Developed by:
-
- Paul G Smith (commstalk hq & Full Moon Software, Inc)
-
- you can leave messages at (UK): 0727 844232; (US): 408 253 7199
- BUT I prefer to be contacted by e-mail
- AppleLink: SMITH.PG
- Internet: SMITH.PG@applelink.apple.com
-
- "SimpliFace" Sample code to accompany develop article
- on techniques for embedding scripts in applications.
-
-
- Apple Event Object Model tokens for SimpliFace
-
- */
-
- #ifndef __AEOMTOKENS__
- #define __AEOMTOKENS__
-
- #ifndef __SimpliFace__
- #include "SimpliFace.h"
- #endif
-
- #ifndef __SimpliFaceCOMMON__
- #include "SimpliFaceCommon.h"
- #endif
-
- #ifndef __APPLEEVENTS__
- #include "AppleEvents.h"
- #endif
-
- #ifndef __PASCALSTRING__
- #include <PascalString.h>
- #endif
-
- #ifndef __SCRIPTOBJECTS__
- #include "ScriptableObjects.h"
- #endif
-
-
-
- // object model classes
-
- class TObjModelToken
- {
- public:
- TObjModelToken(void); // constructor
- TObjModelToken(DescType theTokenClass,
- TScriptableObject* theObj); // initialise
- TObjModelToken(const TObjModelToken&); // initialise
- virtual ~TObjModelToken(void); // virtual destructor
- TObjModelToken& operator=(const TObjModelToken&);
-
- virtual TObjModelToken* MakeClone(void);
-
- // support for object accessors
-
- virtual TObjModelToken* MakeNewToken(DescType theTokenClass,
- TScriptableObject* theObj);
-
- virtual OSErr ResolveElement(DescType desiredClass,
- DescType keyForm,
- AEDesc *keyData,
- TObjModelToken **theResultToken);
-
- virtual OSErr ResolveProperty(DescType desiredClass,
- DescType keyForm,
- AEDesc *keyData,
- TObjModelToken **theResultToken);
-
-
- virtual OSErr DispatchAppleEvent(AppleEvent *theEvent,
- AppleEvent *theReply,
- AEEventClass theEvtClass,
- AEEventID theEvtID);
-
- OSErr CallDispatchAppleEvent(AppleEvent *theEvent,
- AppleEvent *theReply,
- AEEventClass theEvtClass,
- AEEventID theEvtID);
-
- inline DescType GetTokenClass(void) { return fTokenClass; } ;
-
- inline TScriptableObject* GetTokenObj(void) { return fTheObject; } ;
-
- protected:
- DescType fTokenClass; // cLine, cWord, cText, cChar, etc
- Boolean fIsProperty;
- DescType fPropertyID;
- TScriptableObject* fTheObject;
-
- // hooks into Apple Event handling, only override for special-purposes;
- // return noErr if Apple Event was handled within the hook function, or
- // errAEEventNotHandled if it was not handled within the hook function
-
- virtual OSErr AECountElems (AppleEvent *theEvent,
- AppleEvent *theReply);
-
- virtual OSErr AECreateElem (AppleEvent *theEvent,
- AppleEvent *theReply);
-
- virtual OSErr AEDeleteElem (AppleEvent *theEvent,
- AppleEvent *theReply);
-
- virtual OSErr AECloseObject (AppleEvent *theEvent,
- AppleEvent *theReply);
-
- virtual OSErr AEGetObjectData (AppleEvent *theEvent,
- AppleEvent *theReply);
-
- virtual OSErr AEOpenObject (AppleEvent *theEvent,
- AppleEvent *theReply);
-
- virtual OSErr AESetObjectData (AppleEvent *theEvent,
- AppleEvent *theReply);
-
-
- };
-
- // -------------------------------------------------------
-
-
- enum {
- typeObjModelToken = 'OBJX' // special descriptor type for our tokens
- };
-
-
- typedef TObjModelToken* objModelTokenPtr;
-
-
-
-
-
- // -------------------------------------------------------
-
- objModelTokenPtr ObjModelTokenFromDesc(AEDesc *theDesc);
-
- OSErr DescFromObjModelToken(const objModelTokenPtr theToken, AEDesc *theDesc);
-
-
- OSErr SFinitAEobjects(void);
- // set up SF object model handlers
-
- OSErr SFendAEobjects(void);
- // detach SF object model handlers & shut down
-
-
-
-
- // object accessors
-
- pascal OSErr PropertyFromNullAccessor (DescType desiredClass,
- AEDesc *containerToken,
- DescType containerClass,
- DescType keyForm,
- AEDesc *keyData,
- AEDesc *theToken,
- long theRefCon);
-
- OSErr MakeAppToken(TObjModelToken** theApplicationToken);
-
- pascal OSErr AppTokenFromNullAccessor (DescType desiredClass,
- AEDesc *containerToken,
- DescType containerClass,
- DescType keyForm,
- AEDesc *keyData,
- AEDesc *theToken,
- long theRefCon);
-
- pascal OSErr WindowTokenFromNullAccessor(DescType desiredClass,
- AEDesc *containerToken,
- DescType containerClass,
- DescType keyForm,
- AEDesc *keyData,
- AEDesc *theToken,
- long theRefCon);
-
- pascal OSErr StdObjectFromNullAccessor (DescType desiredClass,
- AEDesc *containerToken,
- DescType containerClass,
- DescType keyForm,
- AEDesc *keyData,
- AEDesc *theToken,
- long theRefCon);
-
-
- static pascal OSErr StdObjectAccessor (DescType desiredClass,
- AEDesc *containerToken,
- DescType containerClass,
- DescType keyForm,
- AEDesc *keyData,
- AEDesc *theToken,
- long theRefCon);
-
- static pascal OSErr StdPropertyAccessor(DescType desiredClass,
- AEDesc *containerToken,
- DescType containerClass,
- DescType keyForm,
- AEDesc *keyData,
- AEDesc *theToken,
- long theRefCon);
-
- // object support callbacks
-
- static pascal OSErr StdCountProc (DescType desiredClass,
- DescType containerClass,
- AEDesc *containerToken,
- long *result);
-
- static pascal OSErr StdCompareProc (DescType comparisonOperator,
- AEDesc object,
- DescType objOrDescToCompare,
- Boolean& result);
-
- static pascal OSErr StdDisposeToken (AEDesc *unneededToken);
-
-
-
- #endif
-